package com.example.shardingjdbcdemo.controller;

import com.example.shardingjdbcdemo.entity.Order;
import com.example.shardingjdbcdemo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {
    
    @Autowired
    private OrderService orderService;
    
    @PostMapping("/create")
    public String createOrder(@RequestBody Order order) {
        orderService.save(order);
        return "创建订单成功";
    }
    
    @GetMapping("/{orderId}")
    public Order getOrder(@PathVariable Long orderId) {
        return orderService.getById(orderId);
    }
}